<template>
    <v-layout>
        <template slot="header"> 组织人员树 </template>
        <template slot="content">
            <div class="exmple-box">
                <VirtualTree
                    :dataSource="treeData"
                    :defaultNodes="[]"
                    @onCheck="handleChange"
                >
                </VirtualTree>
            </div>
        </template>
    </v-layout>
</template>

<script>
import vLayout from "@/components/vLayout";
import VirtualTree from "@/components/vOrgPersonTree/index.vue";
export default {
    components: {
        vLayout,
        VirtualTree,
    },
    data() {
        return {
            treeData: [
                {
                    id: "0",
                    name: "根节点",
                    nodeType: 2,
                    children: [
                        {
                            id: "1",
                            name: "组织1",
                            nodeType: 2,
                            children: [
                                {
                                    id: "1-1",
                                    name: "人员1-1",
                                    nodeType: 13,
                                },
                                {
                                    id: "1-2",
                                    name: "组织1-2",
                                    nodeType: 2,
                                    children: [
                                        {
                                            id: "1-2-1",
                                            name: "人员1-2-1",
                                            nodeType: 13,
                                        },
                                        {
                                            id: "1-2-2",
                                            name: "人员1-2-2",
                                            nodeType: 13,
                                        },
                                    ],
                                },
                            ],
                        },
                        {
                            id: "2",
                            name: "组织2",
                            nodeType: 2,
                            children: [],
                        },
                    ],
                },
            ],
        };
    },
    methods: {
        handleChange(checkedNodes) {
            console.log("当前选中的节点:", checkedNodes);
        },
    },
    mounted() {
        for (let i = 0; i < 2000; i++) {
            this.treeData[0].children[1].children.push({
                id: "2-" + i,
                name: "人员2-" + i,
                nodeType: 13,
            });
        }
    },
};
</script>

<style lang="less" scoped>
.exmple-box {
    height: 100%;
}
</style>
